<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>
     <style type="text/css">
         .content{
            width: 200px;
            height: 80px;
            text-align: left;

          }
    </style>
    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" role="form" action="{:U('Food/edit')}" method="post">
                            <input type="hidden" name="id" value="{$data['id']}" />
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 保健老师 </label>
                                <div class="col-sm-9">
                                    <select id="doctor" name="doctor" class="multiselect">
                                        <option value="0">--请选择保健老师--</option>
                                        <volist name="teacher" id="val">
                                            <option <if condition="$data['doctor'] eq $val['uid']">selected</if> value="{:$val['uid']}">{:$val['name']}</option>
                                        </volist>
                                    </select>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 标题 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="title" id="title" class="col-xs-10 col-sm-5" placeholder="如：第2周食谱安排" value="{:$data['title']}">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle"></span>
                                            </span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 食谱表 </label>
                                <div class="col-xs-9 col-sm-9" id="course">
                                        <div id='time'></div>
                                        <!-- <a href="javascript:void(0);" id="last-week">上一周</a><a href="javascript:void(0);" id="next-week">下一周</a> -->
                                        <table id="monitor" class="table table-striped table-bordered">
                                            <volist name="data['time']" id='val'>
                                                <tr>
                                                    <td><input type="text" readonly="readonly" class='time' value="{$val['time']|date='Y-m-d',###}-星期{:date('N',$val['time'])}" /></td>
                                                    <td>早餐</td>
                                                    <td><textarea class="content" name='bf[]'>{$val.bf}</textarea><br />用餐时间<input type="text" name="bf_time[]" class="timeRange" value="{$val.bf_time}" placeholder="00:00" readonly="readonly" /></td>
                                                    <td>上午加餐</td>
                                                    <td><textarea class="content" name='bf_ext[]'>{$val.bf_ext}</textarea><br />用餐时间<input type="text" name="bf_ext_time[]" value="{$val.bf_ext_time}" readonly="readonly" placeholder="00:00" class="timeRange" /></td>
                                                    <td>午餐</td>
                                                    <td><textarea class="content" name='lunch[]'>{$val.lunch}</textarea><br />用餐时间<input type="text" name="l_time[]" class="timeRange" value="{$val.l_time}" readonly="readonly" placeholder="00:00" /></td>
                                                    <td>下午加餐</td>
                                                    <td><textarea class="content" name='l_ext[]'>{$val.l_ext}</textarea><br />用餐时间<input type="text" name="l_ext_time[]" value="{$val.l_ext_time}" readonly="readonly" placeholder="00:00" class="timeRange" /></td>
                                                    <td>晚餐</td>
                                                    <td><textarea class="content" name='dinner[]'>{$val.dinner}</textarea><br />用餐时间<input type="text" name="d_time[]" class="timeRange" value="{$val.d_time}" readonly="readonly" placeholder="00:00" /></td>
                                                </tr>   
                                                <!-- <tr>
                                                    <td><input type="text" disabled="disabled" class='time' value="{$val['time']|date='Y-m-d',###}-星期{:date('N',$val['time'])}" /></td>
                                                    <td>早餐</td>
                                                    <td><input type="text" name='bf[]' value="{$val.bf}" placeholder="无" /><br />用餐时间<input type="text" readonly="readonly" name="bf_time[]" class="timeRange" value="{$val.bf_time}" placeholder="00:00" /></td>
                                                    <td>上午加餐</td>
                                                    <td><input type="text" name='bf_ext[]' placeholder="无"  value="{$val.bf_ext}" /><br />用餐时间<input type="text" readonly="readonly" name="bf_ext_time[]" value="{$val.bf_ext_time}" placeholder="00:00" class="timeRange" /></td>
                                                    <td>午餐</td>
                                                    <td><input type="text" name='lunch[]' value="{$val.lunch}" placeholder="无" /><br />用餐时间<input type="text" readonly="readonly" name="l_time[]" class="timeRange" value="{$val.l_time}" placeholder="00:00" /></td>
                                                    <td>下午加餐</td>
                                                    <td><input type="text" name='l_ext[]' value="{$val.l_ext}" placeholder="无" /><br />用餐时间<input type="text" readonly="readonly" name="l_ext_time[]" value="{$val.l_ext_time}" placeholder="00:00" class="timeRange" /></td>
                                                    <td>晚餐</td>
                                                    <td><input type="text" name='dinner[]' value="{$val.dinner}" placeholder="无" /><br />用餐时间<input type="text" readonly="readonly" name="d_time[]" class="timeRange" value="{$val.d_time}" placeholder="00:00" /></td>
                                                </tr> -->
                                            </volist>
                                        </table>
                                        <span style='color:red' class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">注：每天的早、中、晚餐必须填写一项。如本天没有，只需在早、中、晚餐某一项中填写（“无”）即可。</span>
                                            </span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript">
    $(function(){
    //
    $('.timeRange').click(function(){
        $('#timeRange_div').remove();
        
        var hourOpts = '';
        for (i=0;i<24;i++) {
            if(i <10){
                hourOpts += '<option>'+'0'+i+'</option>';
            }else{
                hourOpts += '<option>'+i+'</option>';
            }
        }
            
        var minuteOpts = '<option>00</option><option>10</option><option>20</option><option>30</option><option>40</option><option>50</option>';
        
        var html = $('<div id="timeRange_div"><select id="timeRange_a">'+hourOpts+
            '</select>:<select id="timeRange_b">'+minuteOpts+
            '</select><input type="button" value="确定" id="timeRange_btn" /></div>')
            .css({
                "position": "absolute",
                "z-index": "999",
                "padding": "5px",
                "border": "1px solid #AAA",
                "background-color": "#FFF",
                "box-shadow": "1px 1px 3px rgba(0,0,0,.4)"
            })
            .click(function(){return false});
        // 如果文本框有值
        var v = $(this).val();
        if (v) {
            v = v.split(/:|-/);
            html.find('#timeRange_a').val(v[0]);
            html.find('#timeRange_b').val(v[1]);
        }
        // 点击确定的时候
        var pObj = $(this);
        html.find('#timeRange_btn').click(function(){
            var str = html.find('#timeRange_a').val()+':'
                +html.find('#timeRange_b').val();
            pObj.val(str);
            $('#timeRange_div').remove();
        });
        
        $(this).after(html);
        return false;
    });
    //
    $(document).click(function(){
        $('#timeRange_div').remove();
    });
    //
});

    $('.submit').click(function(event) {
        var name = $('#name').val();
        var t_id = $('#t_id').val();
        var price = $('#price').val();
        var desc = $('#desc').val();
        if (name == '') {
            bootbox.dialog({
                title: '友情提示：',
                message: "班级名称必须填写!",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        // if (t_id == 0) {
        //     bootbox.dialog({
        //         title: '友情提示：',
        //         message: "请选择班主任!",
        //         buttons: {
        //             "success": {
        //                 "label": "确定",
        //                 "className": "btn-danger"
        //             }
        //         }
        //     });
        //     return;
        // }
        if (price == '') {
            bootbox.dialog({
                title: '友情提示：',
                message: "请填写报名费用!",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        if (isNaN(price)) {
            bootbox.dialog({
                title: '友情提示：',
                message: "报名费用为阿拉伯数字!",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        if (desc == '') {
            bootbox.dialog({
                title: '友情提示：',
                message: "请填写班级简介!",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
            return;
        }
        $('#form').submit();
    });
</script>
</body>
</html>
